package com.king.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.net.URLDecoder;

@Controller
public class IndexController extends BaseController {

    @RequestMapping({"", "/", "index"})
    public String index(){

        //参数：1分页信息 2分类 3用户 4置顶 5精选 6排序
        IPage results = mPostService.paging(getPage(),null,null,null,null,"created");
        request.setAttribute("pageData",results);

        request.setAttribute("currentCategoryId",0);
        return "index";
    }

    @RequestMapping("/search")
    public String search(String q){
        IPage pageData = searchService.search(getPage(),q);

        request.setAttribute("q",q);
        request.setAttribute("pageData",pageData);
        return "search";
    }
}
